home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Java for 3D & VRML Worlds
/
Java for 3d and VRML Worlds.iso
/
multiuser
/
circus2
/
scripts
/
circus.java
< prev
Encoding:
Amiga
Atari
Commodore
DOS
FM Towns/JPY
Macintosh
Macintosh JP
NeXTSTEP
RISC OS/Acorn
UTF-8
Wrap
Java Source
|
1996-09-25
|
39.3 KB
|
1,541 lines
/*
* File : circus.java (Circus Park 2 for Community Place)
* Version : 2.0- 1996.09.10
* Auther : cori co.
*
* Copyright(C) 1996 Sony Corporation. All rights reserved.
*/
import vrml.*;
import vrml.field.*;
import vrml.node.*;
import java.util.*;
import vs.*;
public class circus extends Script {
static int X = 0;
static int Y = 1;
static int Z = 2;
static int DEGREE = 3;
static int R = 0;
static int G = 1;
static int B = 2;
float Radian = 180.0f / (float)Math.PI;
/* Node */
SFNode WorldNode;
/* World */
SFBool WorldTimer;
MFColor WorldSkyCol;
SFInt32 WorldLightSwitch;
//SFVec3f RocketmanPos;
SFRotation AirShipRot;
/* Ferris */
SFColor FerrisRideCol;
SFVec3f FerrisRidePos;
SFVec3f FerrisExitPos;
SFVec3f FerrisWheelPos;
SFRotation FerrisWheelRot;
SFVec3f GondolaFloorPos;
SFVec3f GondolaFencePos;
SFTime GondolaSound_start;
SFTime GondolaSound_stop;
SFRotation GondolaRot[] = new SFRotation[10];
SFVec3f GondolaPos[] = new SFVec3f[10];
/* view point */
SFBool GondolaViewBind;
SFRotation GondolaViewRot;
/* parade sound */
SFRotation ParadeStageRot;
SFVec3f ParadeSoundPos;
SFTime ParadeSound_start;
SFTime ParadeSound_stop;
/* Piero1 with Accordion */
SFBool Piero1Sw;
SFTime Piero1StartTime;
SFTime Piero1StopTime;
SFVec3f Piero1Pos;
SFRotation Piero1Rot;
SFVec3f AccordionPos;
SFVec3f Accordion1Pos;
SFVec3f Accordion2Pos;
SFRotation AccordionRot;
/* Piero2 with Barrel */
SFBool Piero2Sw;
SFTime Piero2StartTime;
SFTime Piero2StopTime;
SFVec3f Piero2Pos;
SFRotation Piero2Rot;
SFVec3f BarrelPos;
SFRotation BarrelRot;
/* Piero3 taller */
SFBool Piero3Sw;
SFTime Piero3StartTime;
SFTime Piero3StopTime;
SFVec3f Piero3Pos;
SFRotation Piero3Rot;
/* Kuma */
SFBool KumaSw;
SFTime KumaStartTime;
SFTime KumaStopTime;
SFVec3f KumaPos;
SFRotation KumaRot;
SFBool KumaBicycleSw;
/* Ashika */
SFBool AshikaSw;
SFTime AshikaStartTime;
SFTime AshikaStopTime;
SFVec3f AshikaPos;
SFRotation AshikaRot;
SFBool AshikaBallSw;
SFVec3f AshikaBallPos;
SFRotation AshikaBallRot;
SFTime AshikaSound_start;
SFTime AshikaSound_stop;
/* World Val */
boolean WorldConstructorInvoked = false;
int WorldSkyFlg = 0;
int ParadeFlg = 0;
int CurrentTime = 60; // 4:00 start sunrise
/*
* this 'time' counts up every second.
* one actual second is 1/15 virtual hour.
* 0 = 0:00 (reset)
* 60 = 4:00 (start sunrise)
* 120 = 8:00 (end sunrise)
* 240 = 16:00(start sunset)
* 300 = 20:00(end sunset)
* 360 = 24:00(wind up the counter)
*/
int EclipseCnt = 0;
int sunriseStartTime = 60;
int sunriseMidStartTime = 70;
int sunriseMidEndTime = 70;
int sunriseEndTime = 120;
int sunsetStartTime = 240;
int sunsetMidStartTime = 250;
int sunsetMidEndTime = 250;
int sunsetEndTime = 300;
float nightColorR = 0.1f;
float nightColorG = 0.1f;
float nightColorB = 0.35f;
float sunriseColorR = 0.60f;
float sunriseColorG = 0.10f;
float sunriseColorB = 0.08f;
float daylightColorR = 0.44f;
float daylightColorG = 0.49f;
float daylightColorB = 1.0f;
float sunsetColorR = 0.60f;
float sunsetColorG = 0.10f;
float sunsetColorB = 0.08f;
int IllumiNo = 0;
int IllumiCnt = 0;
float IllumiR = 1.0f;
float IllumiG = 1.0f;
float IllumiB = 1.0f;
/* Ferris Val */
boolean FerrisRideColorSw = true;
float FerrisWheelR = ( 28.5f - 6.0f );
float FerrisWheelY = 28.5f;
float FerrisRotateAngle = 0.0f;
int RideGondolaNum = 0;
int RidePerson = 0;
int RideSeat = 0;
/* Piero val */
boolean Piero1MoveFlg = false;
boolean Piero2MoveFlg = false;
boolean Piero3MoveFlg = false;
int Piero1Cnt = 0;
int Piero2Cnt = 0;
int Piero3Cnt = 0;
int Piero2Dir = 0;
float Piero2PosZ = 0.0f;
float Piero2RotD = 0.0f;
/* Ashika */
boolean AshikaMoveFlg = false;
int AshikaCnt = 0; /* current position */
int AshikaMode = 0; /* current mode */
float AshikaBallRotX = 0.0f;
float AshikaBallRotZ = 0.0f;
float AshikaBallData1[][] = { /* original position <-> ashika */
{38.4f,0.4f},
{38.1f,0.9f},
{37.8f,1.25f},
{37.5f,1.5f},
{37.2f,1.6f},
{36.9f,1.8f},
{36.6f,1.9f},
{36.3f,1.9f},
{36.0f,1.8f},
{35.7f,1.6f},
};
float AshikaBallData2[] = { /* on the ashika */
1.6f,1.7f,1.8f,1.9f,2.0f,2.0f,1.9f,1.8f,1.7f,1.6f
};
/* Kuma 8 */
boolean KumaMoveFlg = false;
float KumaAng = 0.0f;
int KumaCnt = 0;
public void initialize() {
WorldNode = (SFNode)getField( "WorldNode" );
/* World */
WorldTimer = (SFBool) getEventOut( "WorldTimer_enabled" );
WorldSkyCol = (MFColor) getEventOut( "WorldSky_color" );
WorldLightSwitch = (SFInt32) getEventOut( "WorldLight_switch" );
//RocketmanPos = (SFVec3f) getEventOut( "WorldRocketman_position" );
AirShipRot = (SFRotation) getEventOut( "Airship_rotation" );
/* Ferris */
FerrisRideCol = (SFColor) getEventOut( "FerrisRide_color" );
FerrisRidePos = (SFVec3f) getEventOut( "FerrisRide_position" );
FerrisExitPos = (SFVec3f) getEventOut( "FerrisExit_position" );
FerrisWheelPos = (SFVec3f) getEventOut( "FerrisWheel_position" );
FerrisWheelRot = (SFRotation) getEventOut( "FerrisWheel_rotation" );
GondolaFloorPos = (SFVec3f) getEventOut( "GondolaFloor_position" );
GondolaFencePos = (SFVec3f) getEventOut( "GondolaFence_position" );
GondolaSound_start = (SFTime) getEventOut( "GondolaSound_start" );
GondolaSound_stop = (SFTime) getEventOut( "GondolaSound_stop" );
GondolaViewBind = (SFBool) getEventOut( "GondolaView_bind" ); //// 1996.08.29
GondolaViewRot = (SFRotation) getEventOut( "GondolaView_rotation" ); //// 1996.09.12h
/* parade sound */
ParadeStageRot = (SFRotation) getEventOut( "ParadeStage_rotation" );
ParadeSoundPos = (SFVec3f) getEventOut( "ParadeSound_position" );
ParadeSound_start = (SFTime) getEventOut( "ParadeSound_start" );
ParadeSound_stop = (SFTime) getEventOut( "ParadeSound_stop" );
/* Piero1 with Accordion */
Piero1Sw = (SFBool) getEventOut( "Piero1_sw" );
Piero1StartTime = (SFTime) getEventOut( "Piero1_start" );
Piero1StopTime = (SFTime) getEventOut( "Piero1_stop" );
Piero1Pos = (SFVec3f) getEventOut( "Piero1_position" );
Piero1Rot = (SFRotation) getEventOut( "Piero1_rotation" );
AccordionPos = (SFVec3f) getEventOut( "Piero1Accordion_position" );
Accordion1Pos = (SFVec3f) getEventOut( "Piero1Accordion1_position" );
Accordion2Pos = (SFVec3f) getEventOut( "Piero1Accordion2_position" );
AccordionRot = (SFRotation) getEventOut( "Piero1Accordion_rotation" );
/* Piero2 with Barrel */
Piero2Sw = (SFBool) getEventOut( "Piero2_sw" );
Piero2StartTime = (SFTime) getEventOut( "Piero2_start" );
Piero2StopTime = (SFTime) getEventOut( "Piero2_stop" );
Piero2Pos = (SFVec3f) getEventOut( "Piero2_position" );
Piero2Rot = (SFRotation) getEventOut( "Piero2_rotation" );
BarrelPos = (SFVec3f) getEventOut( "Piero2Barrel_position" );
BarrelRot = (SFRotation) getEventOut( "Piero2Barrel_rotation" );
/* Piero3 taller */
Piero3Sw = (SFBool) getEventOut( "Piero3_sw" );
Piero3StartTime = (SFTime) getEventOut( "Piero3_start" );
Piero3StopTime = (SFTime) getEventOut( "Piero3_stop" );
Piero3Pos = (SFVec3f) getEventOut( "Piero3_position" );
Piero3Rot = (SFRotation) getEventOut( "Piero3_rotation" );
/* Kuma */
KumaSw = (SFBool) getEventOut( "Kuma_sw" );
KumaStartTime = (SFTime) getEventOut( "Kuma_start" );
KumaStopTime = (SFTime) getEventOut( "Kuma_stop" );
KumaPos = (SFVec3f) getEventOut( "Kuma_position" );
KumaRot = (SFRotation) getEventOut( "Kuma_rotation" );
KumaBicycleSw = (SFBool) getEventOut( "Kuma_bicycle_sw" );
/* Ashika */
AshikaSw = (SFBool) getEventOut( "Ashika_sw" );
AshikaStartTime = (SFTime) getEventOut( "Ashika_start" );
AshikaStopTime = (SFTime) getEventOut( "Ashika_stop" );
AshikaPos = (SFVec3f) getEventOut( "Ashika_position" );
AshikaRot = (SFRotation) getEventOut( "Ashika_rotation" );
AshikaBallSw = (SFBool) getEventOut( "AshikaBall_sw" );
AshikaBallPos = (SFVec3f) getEventOut( "AshikaBall_position" );
AshikaBallRot = (SFRotation) getEventOut( "AshikaBall_rotation" );
AshikaSound_start = (SFTime) getEventOut( "AshikaSound_start" );
AshikaSound_stop = (SFTime) getEventOut( "AshikaSound_stop" );
}
public void processEvent(Event e) {
String name = e.getName();
double now = e.getTimeStamp();
/* World */
if ( name.equals( "WorldMove" )) {
WorldMove( (ConstSFTime)e.getValue(), now );
} else if ( name.equals( "WorldSync" )) {
WorldSync( (ConstSFString)e.getValue(), now );
} else if ( name.equals( "ShareFerrisRotate" )) {
ShareFerrisRotate( (ConstSFString)e.getValue(), now );
} else if ( name.equals( "ShareRidePerson" )) {
ShareRidePerson( (ConstSFString)e.getValue(), now );
} else if ( name.equals( "ShareCurrentTime" )) {
ShareCurrentTime( (ConstSFString)e.getValue(), now );
} else if ( name.equals( "FerrisRide" )) {
FerrisRide( (ConstSFString)e.getValue(), now );
} else if ( name.equals( "EclipsePick" )) {
EclipsePick( (ConstSFBool)e.getValue(), now );
} else if ( name.equals( "EclipsePickShare" )) {
EclipsePickShare( (ConstSFString)e.getValue(), now );
/* Ferris */
} else if ( name.equals( "FerrisRidePick" )) {
FerrisRidePick( (ConstSFBool)e.getValue(), now );
} else if ( name.equals( "FerrisExitPick" )) {
FerrisExitPick( (ConstSFBool)e.getValue(), now );
/* Piero */
} else if ( name.equals( "Piero1PickShare" )) {
Piero1PickShare( (ConstSFString)e.getValue(), now );
} else if ( name.equals( "Piero1Pick" )) {
Piero1Pick( (ConstSFBool)e.getValue(), now );
} else if ( name.equals( "Piero2PickShare" )) {
Piero2PickShare( (ConstSFString)e.getValue(), now );
} else if ( name.equals( "Piero2Pick" )) {
Piero2Pick( (ConstSFBool)e.getValue(), now );
} else if ( name.equals( "Piero3PickShare" )) {
Piero3PickShare( (ConstSFString)e.getValue(), now );
} else if ( name.equals( "Piero3Pick" )) {
Piero3Pick( (ConstSFBool)e.getValue(), now );
/* Ashika */
} else if ( name.equals( "AshikaPickShare" )) {
AshikaPickShare( (ConstSFString)e.getValue(), now );
} else if ( name.equals( "AshikaPick" )) {
AshikaPick( (ConstSFBool)e.getValue(), now );
} else if ( name.equals( "AshikaBallMove" )) {
AshikaBallMove( (ConstSFTime)e.getValue(), now );
} else if ( name.equals( "AshikaBallPickShare" )) {
AshikaBallPickShare( (ConstSFString)e.getValue(), now );
} else if ( name.equals( "AshikaBallPick" )) {
AshikaBallPick( (ConstSFBool)e.getValue(), now );
/* Kuma */
} else if ( name.equals( "KumaPickShare" )) {
KumaPickShare( (ConstSFString)e.getValue(), now );
} else if ( name.equals( "KumaPick" )) {
KumaPick( (ConstSFBool)e.getValue(), now );
} else if ( name.equals( "KumaBicycleMove" )) {
KumaBicycleMove( (ConstSFTime)e.getValue(), now );
} else {
;
}
}
/* --------------------------------------------------------------- */
/*
* notice: in the constructor, you cannot send events to other nodes
* using ROUTEs.
*/
void world_constructor ( double now ) {
GondolaRot[0] = (SFRotation) getEventOut( "Gondola0_rotation" );
GondolaRot[1] = (SFRotation) getEventOut( "Gondola1_rotation" );
GondolaRot[2] = (SFRotation) getEventOut( "Gondola2_rotation" );
GondolaRot[3] = (SFRotation) getEventOut( "Gondola3_rotation" );
GondolaRot[4] = (SFRotation) getEventOut( "Gondola4_rotation" );
GondolaRot[5] = (SFRotation) getEventOut( "Gondola5_rotation" );
GondolaRot[6] = (SFRotation) getEventOut( "Gondola6_rotation" );
GondolaRot[7] = (SFRotation) getEventOut( "Gondola7_rotation" );
GondolaPos[0] = (SFVec3f)getEventOut( "Gondola0_position" );
GondolaPos[1] = (SFVec3f)getEventOut( "Gondola1_position" );
GondolaPos[2] = (SFVec3f)getEventOut( "Gondola2_position" );
GondolaPos[3] = (SFVec3f)getEventOut( "Gondola3_position" );
GondolaPos[4] = (SFVec3f)getEventOut( "Gondola4_position" );
GondolaPos[5] = (SFVec3f)getEventOut( "Gondola5_position" );
GondolaPos[6] = (SFVec3f)getEventOut( "Gondola6_position" );
GondolaPos[7] = (SFVec3f)getEventOut( "Gondola7_position" );
ShapePosInit();
if ( Vscp.amIMaster()) {
/* don't share */
} else {
Vscp.sendApplSpecificMsgWithDist( WorldNode, "WorldSync", "dummy", Vscp.responderOnly );
}
}
/*
* share WorldValue
*/
public void WorldSync ( ConstSFString shared_data, double now ) {
String s;
if ( Vscp.amIMaster()) {
s = String.valueOf( FerrisRotateAngle );
Vscp.sendApplSpecificMsgWithDist( WorldNode, "ShareFerrisRotate", s, Vscp.allClientsExceptMe );
s = String.valueOf( RidePerson );
Vscp.sendApplSpecificMsgWithDist( WorldNode, "ShareRidePerson", s, Vscp.allClientsExceptMe );
s = String.valueOf( CurrentTime );
Vscp.sendApplSpecificMsgWithDist( WorldNode, "ShareCurrentTime", s, Vscp.allClientsExceptMe );
}
}
/*
*
*/
public void ShareFerrisRotate ( ConstSFString shared_data, double now ) {
String s;
s = shared_data.getValue();
FerrisRotateAngle = Float.valueOf( s ).floatValue();
FerrisMove( now );
}
/*
* set ride
*/
public void ShareRidePerson ( ConstSFString shared_data, double now ) {
String s;
// < set world valiable >
s = shared_data.getValue();
RidePerson = Integer.valueOf( s ).intValue();
}
/*
* set CurrentTime
*/
public void ShareCurrentTime ( ConstSFString shared_data, double now ) {
String s;
s = shared_data.getValue();
CurrentTime = Integer.valueOf( s ).intValue();
}
/*
*
*/
public void WorldMove ( ConstSFTime t, double now ) {
String s;
/* this function should be invoked only once at the first time! */
if(false == WorldConstructorInvoked){
WorldTimer.setValue( false );
world_constructor( now );
WorldConstructorInvoked = true;
WorldTimer.setValue( true );
}
/* change the color */
FerrisRideColor();
if (( CurrentTime & 1 ) == 0 ) {
FerrisMove( now );
}
/* Airship rotation */
if (( CurrentTime & 3 ) == 2 ) {
AirshipMove( t, now );
if ( Vscp.amIMaster()) { ////960906c test
Vscp.sendApplSpecificMsgWithDist( WorldNode, "WorldSync", "dummy", Vscp.responderOnly );
}
}
if ( EclipseCnt > 0 ) {
EclipseCnt--;
if ( EclipseCnt <= 0 ) {
EclipseReset();
}
} else {
ChangeBgColor( t, now );
}
if ( CurrentTime == 90 ) {
WorldLightSwitch.setValue( 0 );
} else if ( CurrentTime == 270 ) {
WorldLightSwitch.setValue( 1 );
ParadeInit( now );
ParadeFlg = 1;
}
if ( ParadeFlg == 1 ) {
if ( CurrentTime > 270 && CurrentTime < 330 ) {
ParadeMove( t, now );
} else if ( CurrentTime == 330 ) {
ParadeEnd( now );
ParadeFlg = 0;
}
} else {
if ( Piero1MoveFlg == true ) Piero1Move();
if ( Piero2MoveFlg == true ) Piero2Move();
}
/* count up */
CurrentTime++;
if ( CurrentTime >= 360 ) {
CurrentTime = 0;
if ( Vscp.amIMaster()) {
Vscp.sendApplSpecificMsgWithDist( WorldNode, "WorldSync", "dummy", Vscp.responderOnly );
}
}
}
/*
*
*/
void FerrisRideColor() {
float col[] = new float[3];
if ( FerrisRideColorSw == true ) {
col[R] = 1.0f; col[G] = 0.0f; col[B] = 0.0f;
FerrisRideColorSw = false;
} else {
col[R] = 0.0f; col[G] = 1.0f; col[B] = 0.0f;
FerrisRideColorSw = true;
}
FerrisRideCol.setValue( col );
}
/*
* Solar Eclipse / turn off the light
*/
public void EclipsePick ( ConstSFBool state, double now ) {
if (state.getValue()) return; /* mouseDown */
Vscp.sendApplSpecificMsgWithDist( WorldNode, "EclipsePickShare", "", Vscp.responderOnly );
EclipseStart();
}
/*
*
*/
public void EclipsePickShare ( ConstSFString userdata, double now ) {
if ( Vscp.amIMaster()) {
Vscp.sendApplSpecificMsgWithDist( WorldNode, "EclipsePickShare", "", Vscp.allClientsExceptMe );
}
EclipseStart();
}
/*
*
*/
public void EclipseStart () {
float[][] col = new float[1][3];
col[0][R] = (float)0.0;
col[0][G] = (float)0.0;
col[0][B] = (float)0.0;
WorldSkyCol.setValue( col );
EclipseCnt = 10;
}
/*
*
*/
public void EclipseReset () {
if ( CurrentTime >= 90 && CurrentTime < 270 ) {
WorldLightSwitch.setValue( 0 );
} else {
WorldLightSwitch.setValue( 1 );
}
//EclipseFlg = 0;
EclipseCnt = 0;
}
/*
*
*/
public void ChangeBgColor ( ConstSFTime t, double now ) {
float red;
float green;
float blue;
float[][] col = new float[1][3];
// < decide bg color >
if ( CurrentTime < sunriseStartTime ) {
WorldSkyFlg++;
red = nightColorR;
green = nightColorG;
blue = nightColorB;
} else if ( CurrentTime < sunriseMidStartTime ) {
WorldSkyFlg = 0;
// < sun rise. (night -> sunrise peak) >
red = calcColorElm( CurrentTime, sunriseStartTime, sunriseMidStartTime, nightColorR, sunriseColorR );
green = calcColorElm( CurrentTime, sunriseStartTime, sunriseMidStartTime, nightColorG, sunriseColorG );
blue = calcColorElm( CurrentTime, sunriseStartTime, sunriseMidStartTime, nightColorB, sunriseColorB );
} else if ( CurrentTime < sunriseMidEndTime ) {
WorldSkyFlg++;
// < sunrise peak.>
red = sunriseColorR;
green = sunriseColorG;
blue = sunriseColorB;
} else if ( CurrentTime < sunriseEndTime ) {
WorldSkyFlg = 0;
// < sun rise. (peak -> daylight) >
red = calcColorElm( CurrentTime, sunriseMidEndTime, sunriseEndTime, sunriseColorR, daylightColorR );
green = calcColorElm( CurrentTime, sunriseMidEndTime, sunriseEndTime, sunriseColorG, daylightColorG );
blue = calcColorElm( CurrentTime, sunriseMidEndTime, sunriseEndTime, sunriseColorB, daylightColorB );
} else if ( CurrentTime < sunsetStartTime ) {
WorldSkyFlg++;
// < daylight.>
red = daylightColorR;
green = daylightColorG;
blue = daylightColorB;
} else if ( CurrentTime < sunsetMidStartTime ) {
WorldSkyFlg = 0;
// < sunset. (daylight -> sunset peak) >
red = calcColorElm( CurrentTime, sunsetStartTime, sunsetMidStartTime, daylightColorR, sunsetColorR );
green = calcColorElm( CurrentTime, sunsetStartTime, sunsetMidStartTime, daylightColorG, sunsetColorG );
blue = calcColorElm( CurrentTime, sunsetStartTime, sunsetMidStartTime, daylightColorB, sunsetColorB );
} else if ( CurrentTime < sunsetMidEndTime ) {
WorldSkyFlg++;
// < sunset peak.>
red = sunsetColorR;
green = sunsetColorG;
blue = sunsetColorB;
} else if ( CurrentTime < sunsetEndTime ) {
WorldSkyFlg = 0;
// < sunset. (peak -> night) >
red = calcColorElm( CurrentTime, sunsetMidEndTime, sunsetEndTime, sunsetColorR, nightColorR );
green = calcColorElm( CurrentTime, sunsetMidEndTime, sunsetEndTime, sunsetColorG, nightColorG );
blue = calcColorElm( CurrentTime, sunsetMidEndTime, sunsetEndTime, sunsetColorB, nightColorB );
} else {
WorldSkyFlg++;
// < night.>
red = nightColorR;
green = nightColorG;
blue = nightColorB;
}
// set bg color
if ( WorldSkyFlg <= 1 ) {
col[0][R] = red;
col[0][G] = green;
col[0][B] = blue;
WorldSkyCol.setValue( col );
} else {
WorldSkyFlg = 2;
}
}
/*
* (endColor - startColor) x (time - startTime)
* color = startColor + ----------------------------------------------------
* endTime - startTime
*
* startColor x (endTime - time) + endColor x (time - startTime)
* = ---------------------------------------------------------------------
* endTime - startTime
*/
public float calcColorElm ( int time, int startTime, int endTime, float startColor, float endColor ) {
float col;
col = (( startColor * ( float )( endTime - time )) + ( endColor * ( float )( time - startTime ))) / ( float )( endTime - startTime );
return( col );
}
/*
* PARADE
*/
public void ParadeInit ( double now ) {
float pos[] = new float[3];
float rot[] = new float[4];
double start_time, end_time;
double parade_time = 60;
pos[X] = 15.0f; pos[Y] = 2.5f; pos[Z] = 0.0f; ParadeSoundPos.setValue( pos );
pos[X] = 13.0f; pos[Y] = 2.5f; pos[Z] = 4.0f; Piero1Pos.setValue( pos );
pos[X] = 13.0f; pos[Y] = 2.5f; pos[Z] = 4.0f; AccordionPos.setValue( pos );
pos[X] = 14.3f; pos[Y] = 2.9f; pos[Z] = 2.0f; Piero2Pos.setValue( pos );
pos[X] = 14.3f; pos[Y] = 2.7f; pos[Z] = 2.0f; BarrelPos.setValue( pos );
pos[X] = 15.0f; pos[Y] = 2.5f; pos[Z] = 0.0f; Piero3Pos.setValue( pos );
pos[X] = 14.3f; pos[Y] = 2.0f; pos[Z] = -2.0f; AshikaPos.setValue( pos );
pos[X] = 13.0f; pos[Y] = 2.5f; pos[Z] = -4.0f; KumaPos.setValue( pos );
rot[X] = 0.0f; rot[Y] = 1.0f; rot[Z] = 0.0f;
rot[DEGREE] = -20.0f / Radian; Piero1Rot.setValue( rot );
AccordionRot.setValue( rot );
rot[DEGREE] = -10.0f / Radian; Piero2Rot.setValue( rot );
BarrelRot.setValue( rot );
rot[DEGREE] = 0.0f / Radian; Piero3Rot.setValue( rot );
rot[DEGREE] = 10.0f / Radian; AshikaRot.setValue( rot );
rot[DEGREE] = 25.0f / Radian; KumaRot.setValue( rot );
//start_time = now.getValue() + 1;
start_time = now + 1;
end_time = start_time + parade_time;
Piero1StartTime.setValue( start_time ); Piero1StopTime.setValue( end_time );
Piero2StartTime.setValue( start_time ); Piero2StopTime.setValue( end_time );
Piero3StartTime.setValue( start_time ); Piero3StopTime.setValue( end_time );
AshikaStartTime.setValue( start_time ); AshikaStopTime.setValue( end_time );
KumaStartTime.setValue( start_time ); KumaStopTime.setValue( end_time );
Piero1Sw.setValue( true );
Piero2Sw.setValue( true );
Piero3Sw.setValue( true );
AshikaSw.setValue( true );
KumaSw.setValue( true );
/* sound on */
ParadeSound_start.setValue( now );
}
/*
*
*/
public void ParadeMove ( ConstSFTime t, double now ) {
float rot[] = new float[ 4 ];
rot[X] = 0.0f; rot[Y] = 1.0f; rot[Z] = 0.0f; rot[DEGREE] = ((float)( CurrentTime - 270 ) * ( -6.0f )) / Radian;
ParadeStageRot.setValue( rot );
rot[X] = 1.0f; rot[Y] = 0.0f; rot[Z] = 0.0f; rot[DEGREE] = 15.0f / Radian;
BarrelRot.setValue( rot );
}
/*
*
*/
public void ParadeEnd ( double now ) {
float rot[] = new float[ 4 ];
rot[X] = 0.0f; rot[Y] = 1.0f; rot[Z] = 0.0f;
rot[DEGREE] = 0.0f / Radian;; ParadeStageRot.setValue( rot );
Piero1Rot.setValue( rot );
AccordionRot.setValue( rot );
rot[DEGREE] = -10.0f / Radian; Piero2Rot.setValue( rot );
BarrelRot.setValue( rot );
rot[DEGREE] = -20.0f / Radian; Piero3Rot.setValue( rot );
rot[DEGREE] = 0.0f / Radian; AshikaRot.setValue( rot ); ////960906c
//rot[DEGREE] = -30.0f / Radian; AshikaRot.setValue( rot );
rot[DEGREE] = 0.0f / Radian; KumaRot.setValue( rot );
//rot[DEGREE] = -45.0f / Radian; KumaRot.setValue( rot );
InterpolatorPosInit(); /* set initial position */
ParadeSound_stop.setValue( now ); /* sound off */
}
/*
*
*/
public void PeriodicIllumi ( ConstSFTime t, ConstSFTime now ) {
// < change color >
//set illumi [ vsGetObjByName "flagall.light0IllumiNo" ]
//?
//vsSetObjAllMaterial illumi vsDiffuse IllumiR IllumiG IllumiB
//?
IllumiNo++;
if ( IllumiNo > 9 ) {
IllumiNo = 0;
IllumiCnt++;
if ( IllumiCnt > 3 ) {
IllumiCnt = 0;
}
// set illumination color
if ( IllumiCnt == 0 ) {
IllumiR = 0.0f;
IllumiG = 0.0f;
IllumiB = 0.0f;
} else if ( IllumiCnt == 1 ) {
IllumiR = 1.0f;
IllumiG = 1.0f;
IllumiB = 1.0f;
} else if ( IllumiCnt == 2 ) {
IllumiR = 1.0f;
IllumiG = 0.0f;
IllumiB = 0.0f;
} else if ( IllumiCnt == 3 ) {
IllumiR = 0.3f;
IllumiG = 1.0f;
IllumiB = 0.1f;
}
}
}
/*
* airship
*/
public void AirshipMove ( ConstSFTime t, double now ) {
float rot[] = new float[4];
//vsRotateAngle Airship 0.0 6.0 0.0 vsCSWorld vsRelative
rot[X] = 0.0f; rot[Y] = 1.0f; rot[Z] = 0.0f;
rot[DEGREE] = ((float)CurrentTime) / Radian;
AirShipRot.setValue( rot );
}
/*
*
*/
public void InterpolatorPosInit () {
float pos[] = new float[3];
Piero1PosInit();
Piero2PosInit();
Piero3PosInit();
AshikaPosInit();
KumaPosInit();
pos[X] = 10.0f; pos[Y] = 2.5f; pos[Z] = 10.0f;
AccordionPos.setValue( pos );
Piero2Dir = 0;
}
/*
*
*/
public void ShapePosInit() {
int i;
float pos[] = new float[3];
float angle;
float th;
/* FerrisWheel */
pos[X] = 0.0f; pos[Y] = 28.5f; pos[Z] = 0.0f;
FerrisWheelPos.setValue( pos );
for ( i = 0; i <= 7; i++ ) {
angle = (((float)i / 8.0f ) * 360.0f) + 90.0f;
//angle = ((float)i / 8.0f ) * 360.0f;
th = angle / Radian;
pos[X] = (float)Math.cos( th ) * FerrisWheelR;
pos[Y] = (float)Math.sin( th ) * FerrisWheelR;
pos[Z] = 0;
GondolaPos[i].setValue( pos );
}
/* FerrisRide Plate */
pos[X] = 0.0f; pos[Y] = 3.5f; pos[Z] = 3.0f;
FerrisRidePos.setValue( pos );
/* FerrisExit Plate */
FerrisExitPosInit();
/* Rocketman */
//pos[X] = 0.0f; pos[Y] = 0.0f; pos[Z] = -80.0f;
//RocketmanPos.setValue( pos );
InterpolatorPosInit();
}
/*
*
*/
float RotateToAngle ( float rotate ) {
float angle;
angle = ( rotate / 72.0f ) * 360.0f;
return angle;
}
/*
*
*/
public void FerrisMove ( double now ) {
int no;
int val;
int i;
float x, y, z;
float pos[] = new float[3];
float rot[] = new float[4];
float rotate, gondola_rotate;
float angle;
float th;
String s;
// Transform personTransform = (Transform)Browser.getPerson();
// set variable
FerrisRotateAngle = FerrisRotateAngle + 1.0f;
if ( FerrisRotateAngle >= 72.0f ) {
FerrisRotateAngle = 0.0f;
}
rotate = FerrisRotateAngle;
/* next Gondola come, clear seat */
val = (int)( rotate % 9 );
if ( val == 0 ) {
RidePerson = 0;
}
/* FerrisWheel */
angle = RotateToAngle( rotate );
th = angle / Radian;
rot[X] = 0.0f; rot[Y] = 0.0f; rot[Z] = 1.0f; rot[DEGREE] = -th;
FerrisWheelRot.setValue( rot );
/* Gondola */
rot[X] = 0.0f; rot[Y] = 0.0f; rot[Z] = 1.0f; rot[DEGREE] = th;
for ( i = 0; i <= 7; i++ ) {
GondolaRot[i].setValue( rot );
}
/* riding on Gondola */
if ( RideGondolaNum > 0 ) {
no = RideGondolaNum - 1;
gondola_rotate = (float)no * 9.0f;
if ( rotate == gondola_rotate ) { /* check ride off */
FerrisExitReset( now ); /* set exit panel to ground */
return;
}
angle = RotateToAngle( rotate - gondola_rotate ) + 90.0f;
th = angle / Radian;
x = ((float)Math.cos( -th ) * FerrisWheelR );
y = ((float)Math.sin( -th ) * FerrisWheelR ) + FerrisWheelY;
z = 0.0f;
/* set person to obj position */
if ( RideSeat == 1 ) {
pos[X] = x; pos[Y] = y - 0.4f; pos[Z] = z - 1.5f;
FerrisExitPos.setValue( pos );
pos[X] = x; pos[Y] = y - 2.5f; pos[Z] = z + 1.0f;
//pos[X] = x; pos[Y] = y - 2.2f; pos[Z] = z + 1.0f;
GondolaFloorPos.setValue( pos );
pos[X] = 0.0f; pos[Y] = 0.7f; pos[Z] = 0.0f;
GondolaFencePos.setValue( pos );
//pos[X] = x; pos[Y] = y - 1.5f; pos[Z] = z + 1.0f;
//personTransform.translate( pos, personTransform.modeAbsolute );
} else {
pos[X] = x; pos[Y] = y - 0.4f; pos[Z] = z + 1.5f;
FerrisExitPos.setValue( pos );
pos[X] = x; pos[Y] = y - 2.5f; pos[Z] = z - 1.0f;
GondolaFloorPos.setValue( pos );
pos[X] = 0.0f; pos[Y] = 0.7f; pos[Z] = 0.0f;
GondolaFencePos.setValue( pos );
//pos[X] = x; pos[Y] = y - 1.5f; pos[Z] = z - 1.0f;
//personTransform.translate( pos, personTransform.modeAbsolute );
}
}
}
/*
* ride on the Ferris
*/
public void FerrisRidePick ( ConstSFBool state, double now ) {
int gondola_num;
float rotate;
float pos[] = new float[3];
float rot[] = new float[4];
String s;
// Transform personTransform = (Transform)Browser.getPerson();
if (state.getValue()) return; /* mouseDown */
if ( RideGondolaNum > 0 ) { /* already ride on */
return;
}
if ( RidePerson >= 2 ) {
return;
}
/* get available Gondola */
rotate = FerrisRotateAngle;
gondola_num = (int)( rotate / 9.0f );
RideGondolaNum = gondola_num + 1; // ride on
GondolaSound_start.setValue( now ); // sound start
GondolaSound_stop.setValue( -1L );
/* select seat */
if ( RidePerson == 0 ) {
RideSeat = 1;
RidePerson = 1;
//rot[X] = 0.0f; rot[Y] = 1.0f; rot[Z] = 0.0f; rot[DEGREE] = 180.0f / Radian;
rot[X] = 0.0f; rot[Y] = 1.0f; rot[Z] = 0.0f; rot[DEGREE] = 0.0f;
} else {
RideSeat = 2;
RidePerson = 2;
//rot[X] = 0.0f; rot[Y] = 1.0f; rot[Z] = 0.0f; rot[DEGREE] = 0.0f;
rot[X] = 0.0f; rot[Y] = 1.0f; rot[Z] = 0.0f; rot[DEGREE] = 180.0f / Radian;
}
GondolaViewBind.setValue( true ); //// 1996.08.29
//// GondolaViewRot.setValue( rot ); //// 1996.09.12h
s = String.valueOf( RideSeat );
Vscp.sendApplSpecificMsgWithDist ( WorldNode, "FerrisRide", s, Vscp.responderOnly );
}
/*
* Share the status of a gondola seat
*/
public void FerrisRide ( ConstSFString shared_data, double now ) {
String s;
if ( Vscp.amIMaster()) {
s = shared_data.getValue();
RidePerson = Integer.valueOf( s ).intValue();
Vscp.sendApplSpecificMsgWithDist ( WorldNode, "ShareRidePerson", s, Vscp.allClientsExceptMe );
}
}
/*
*
*/
public void FerrisExitPosInit () {
float pos[] = new float[ 3 ];
/* set exit panel to ground */
pos[X] = 0.0f; pos[Y] = 0.0f; pos[Z] = 0.0f;
FerrisExitPos.setValue( pos );
//pos[X] = 0.0f; pos[Y] = 0.0f; pos[Z] = 0.0f; ////960904c
//pos[X] = 0.0f; pos[Y] = 2.0f; pos[Z] = 0.0f; ////960909c
pos[X] = 0.0f; pos[Y] = 3.5f; pos[Z] = -2.5f; ////960912h
GondolaFloorPos.setValue( pos );
pos[X] = 0.0f; pos[Y] = -1.0f; pos[Z] = 0.0f; ////960912h
GondolaFencePos.setValue( pos );
}
/*
*
*/
public void FerrisExitReset ( double now ) {
// 1996.08.27
////960904c GondolaViewBind.setValue( false );
RideGondolaNum = 0;
RideSeat = 0;
FerrisExitPosInit();
GondolaSound_stop.setValue( now ); /* sound off */
}
/*
*
*/
public void FerrisExitPick ( ConstSFBool state, double now ) {
float pos[] = new float[ 3 ];
if (state.getValue()) return; /* mouseDown */
FerrisExitReset( now );
}
/*
* for PIERO1
*/
public void Piero1PosInit () {
float pos[] = new float[3];
pos[X] = 10.0f; pos[Y] = 2.5f; pos[Z] = 10.0f;
Piero1Pos.setValue( pos );
}
public void Piero1Pick ( ConstSFBool state, double now ) {
if (state.getValue()) return; /* mouseDown */
Piero1Start( now );
Vscp.sendApplSpecificMsgWithDist(WorldNode, "Piero1PickShare", "void", Vscp.allClientsExceptMe );
}
public void Piero1PickShare ( ConstSFString userdata, double now ) {
Piero1Start( now );
}
/*
*
*/
public void Piero1Start ( double now ) {
double time;
time = now; Piero1StartTime.setValue( time );
//time += 5; Piero1StopTime.setValue( time );
time += 8; Piero1StopTime.setValue( time ); //1996.08.26
Piero1MoveFlg = true;
Piero1Sw.setValue( true );
}
/*
*
*/
public void Piero1Move () {
float pos[] = new float[3];
if ( Piero1Cnt >= 8 ) {
Piero1Sw.setValue( false );
Piero1MoveFlg = false;
Piero1Cnt = 0;
} else {
pos[X] = 0.0f; pos[Y] = 0.0f; pos[Z] = 0.0f;
if (( Piero1Cnt & 1 ) == 0 ) {
pos[X] = 0.03f; Accordion1Pos.setValue( pos );
pos[X] = -0.03f; Accordion2Pos.setValue( pos );
} else {
pos[X] = -0.03f; Accordion1Pos.setValue( pos );
pos[X] = 0.03f; Accordion2Pos.setValue( pos );
}
Piero1Cnt++;
}
}
/*
* PIERO2
*/
public void Piero2PosInit () {
float pos[] = new float[3];
pos[X] = -10.0f; pos[Y] = 2.9f; pos[Z] = 5.0f; Piero2Pos.setValue( pos );
pos[X] = -10.0f; pos[Y] = 2.7f; pos[Z] = 5.0f; BarrelPos.setValue( pos );
Piero2PosZ = 0.0f;
}
public void Piero2Pick ( ConstSFBool state, double now ) {
if (state.getValue()) return; /* mouseDown */
Piero2Start( now );
Vscp.sendApplSpecificMsgWithDist( WorldNode, "Piero2PickShare", "void", Vscp.allClientsExceptMe );
}
/*
*
*/
public void Piero2PickShare ( ConstSFString userdata, double now ) {
Piero2Start( now );
}
/*
*
*/
public void Piero2Start ( double now ) {
double time;
time = now; Piero2StartTime.setValue( time );
time += 4; Piero2StopTime.setValue( time );
Piero2Sw.setValue( true );
Piero2MoveFlg = true;
}
/*
*
*/
public void Piero2Move () {
float pos[] = new float[3];
float rot[] = new float[4];
if ( Piero2Cnt >= 8 ) {
Piero2Cnt = 0;
if ( Piero2Dir == 0 ) {
Piero2Dir = 1;
} else {
Piero2Dir = 0;
}
Piero2MoveFlg = false;
return;
}
if ( Piero2Dir == 0 ) {
Piero2PosZ += 0.1f;
Piero2RotD += 15.0f;
} else {
Piero2PosZ -= 0.1f;
Piero2RotD -= 15.0f;
}
pos[X] = -10.0f; pos[Y] = 2.9f; pos[Z] = 5.0f + Piero2PosZ; Piero2Pos.setValue( pos );
pos[X] = -10.0f; pos[Y] = 2.7f; pos[Z] = 5.0f + Piero2PosZ; BarrelPos.setValue( pos );
rot[X] = 1.0f; rot[Y] = 0.0f; rot[Z] = 0.0f; rot[DEGREE] = Piero2RotD / Radian;
BarrelRot.setValue( rot );
Piero2Cnt++;
}
/*
* for PIERO3
*/
public void Piero3PosInit () {
float pos[] = new float[3];
pos[X] = -3.0f; pos[Y] = 0.8f; pos[Z] = -40.0f;
Piero3Pos.setValue( pos );
}
public void Piero3Pick ( ConstSFBool state, double now ) {
if (state.getValue()) return; /* mouseDown */
Piero3Start( now );
Vscp.sendApplSpecificMsgWithDist( WorldNode, "Piero3PickShare", "void", Vscp.allClientsExceptMe );
}
public void Piero3PickShare ( ConstSFString userdata, double now ) {
Piero3Start( now );
}
/*
*
*/
public void Piero3Start ( double now ) {
double time;
time = now; Piero3StartTime.setValue( time );
time += 4; Piero3StopTime.setValue( time );
Piero3Sw.setValue( true );
}
/*
* for KUMA
*/
public void KumaPosInit () {
float pos[] = new float[3];
pos[X] = -30.0f; pos[Y] = 0.2f; pos[Z] = -30.0f;
KumaPos.setValue( pos );
}
public void KumaPick ( ConstSFBool state, double now ) {
if (state.getValue()) return; /* mouseDown */
KumaStart( now );
Vscp.sendApplSpecificMsgWithDist( WorldNode, "KumaPickShare", "void", Vscp.allClientsExceptMe );
}
public void KumaPickShare ( ConstSFString userdata, double now ) {
KumaStart( now );
}
/*
*
*/
public void KumaStart ( double now ) {
double time;
//1996.08.26
if ( ParadeFlg != 1 ) {
if (KumaCnt>0) {
return;
} else {
KumaAng = 0.0f;
KumaCnt = 0;
time = now; KumaStartTime.setValue( time );
//time += 36; KumaStopTime.setValue( time );
time += 20; KumaStopTime.setValue( time ); //1996.08.26
KumaSw.setValue( true );
KumaBicycleSw.setValue( true );
}
}
}
public void KumaBicycleMove ( ConstSFTime t, double now ) {
float pos[] = new float[3];
float rot[] = new float[4];
float th;
float kuma_x = -30f;
float kuma_y = 0.2f;
float kuma_z = -30f;
float circle_r = 1.5f;
String s;
if ( ParadeFlg != 1 ) { ////960904c
if ( KumaCnt < 18 ) {
KumaAng += 20.0f;
th = KumaAng / Radian;
pos[X] = ((float)Math.cos( th ) * circle_r ) + kuma_x - circle_r;
pos[Z] = ((float)Math.sin( th ) * circle_r ) + kuma_z;
pos[Y] = kuma_y;
} else if ( KumaCnt < 36 ) {
KumaAng -= 20.0f;
th = (KumaAng + 180.0f) / Radian;
pos[X] = ((float)Math.cos( th ) * circle_r ) + kuma_x + circle_r;
pos[Z] = ((float)Math.sin( th ) * circle_r ) + kuma_z;
pos[Y] = kuma_y;
} else {
KumaAng = 0.0f;
KumaCnt = -1;
pos[X] = kuma_x;
pos[Z] = kuma_z;
pos[Y] = kuma_y;
KumaBicycleSw.setValue( false );
}
rot[X] = 0.0f; rot[Y] = 1.0f; rot[Z] = 0.0f; rot[DEGREE] = -KumaAng / Radian;
KumaRot.setValue( rot );
KumaPos.setValue( pos );
KumaCnt++;
} ////960904c
}
/*
* ASHIKA
*/
public void AshikaPosInit () {
float pos[] = new float[3];
pos[X] = -60.0f; pos[Y] = 0.0f; pos[Z] = 35.0f;
AshikaPos.setValue( pos );
}
public void AshikaPick ( ConstSFBool state, double now ) {
if (state.getValue()) return; /* mouseDown */
AshikaStart( now );
Vscp.sendApplSpecificMsgWithDist( WorldNode, "AshikaPickShare", "void", Vscp.allClientsExceptMe );
}
public void AshikaPickShare ( ConstSFString userdata, double now ) {
AshikaStart( now );
}
/*
*
*/
public void AshikaStart ( double now ) {
double time;
time = now;
AshikaStartTime.setValue( time );
time += 1;
AshikaStopTime.setValue( time );
AshikaSw.setValue( true );
}
/*
* ball clicked
*/
public void AshikaBallPick ( ConstSFBool state, double now ) {
if (state.getValue()) return; /* mouseDown */
Vscp.sendApplSpecificMsgWithDist( WorldNode, "AshikaBallPickShare", "void", Vscp.allClientsExceptMe );
AshikaBallStart( now );
}
public void AshikaBallPickShare ( ConstSFString userdata, double now ) {
AshikaBallStart( now );
}
public void AshikaBallStart ( double now ) {
//1996.08.26
if ( ParadeFlg != 1 ) {
AshikaBallSw.setValue( true );
//AshikaStart( now );
}
}
/*
* ashika sound on/off
*/
public void AshikaSound( double now, boolean sw ) {
if ( sw == true ) {
AshikaSound_start.setValue( now ); /* start */
} else {
AshikaSound_stop.setValue( now ); /* stop */
}
}
/*
* ashika's show action
*/
public void AshikaBallMove ( ConstSFTime t, double now ) {
float pos[] = new float[3];
float rot[] = new float[4];
double time;
int a;
AshikaBallRotX -= 10.0f;
AshikaBallRotZ += 20.0f;
rot[X] = 1.0f; rot[Y] = 0.0f; rot[Z] = 0.0f; rot[DEGREE] = AshikaBallRotX / Radian;
AshikaBallRot.setValue( rot );
rot[X] = 0.0f; rot[Y] = 0.0f; rot[Z] = 1.0f; rot[DEGREE] = AshikaBallRotZ / Radian;
AshikaBallRot.setValue( rot );
AshikaStart( now );
AshikaCnt++;
if ( AshikaMode == 0 ) {
if ( AshikaCnt > 10 ) {
AshikaCnt = 0;
AshikaMode++;
//AshikaStart( now );
AshikaSound( now, true );
} else {
a = AshikaCnt - 1;
pos[0] = -60.0f;
pos[1] = AshikaBallData1[a][1];
pos[2] = AshikaBallData1[a][0];
AshikaBallPos.setValue( pos );
}
} else if ( AshikaMode == 1 ) {
if ( AshikaCnt > 10 ) {
AshikaCnt = 0;
AshikaMode++;
AshikaSound( now, true );
AshikaSw.setValue( false );
} else {
a = AshikaCnt - 1;
pos[X] = -60.0f;
pos[Y] = AshikaBallData2[a];
pos[Z] = 35.7f;
AshikaBallPos.setValue( pos );
}
} else if ( AshikaMode == 2 ) {
if ( AshikaCnt == 0 ) {
AshikaSound( now, false );
} else if ( AshikaCnt > 10 ) {
AshikaBallSw.setValue( false );
AshikaMode = 0;
AshikaCnt = 0;
} else {
a = ( 10 - AshikaCnt );
pos[X] = -60.0f;
pos[Y] = AshikaBallData1[a][1];
pos[Z] = AshikaBallData1[a][0];
AshikaBallPos.setValue( pos );
}
}
}
}